/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package podologia.beansDB;

import java.beans.PropertyChangeListener;
import java.beans.PropertyChangeSupport;
import java.io.Serializable;
import java.util.Collection;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.persistence.Transient;

/**
 *
 * @author Hernan
 */
@Entity
@Table(name = "pago")
@NamedQueries({@NamedQuery(name = "Pago.findByNroFactura", query = "SELECT p FROM Pago p WHERE p.nroFactura = :nroFactura"), @NamedQuery(name = "Pago.findByFecha", query = "SELECT p FROM Pago p WHERE p.fecha = :fecha"), @NamedQuery(name = "Pago.findByIdPaciente", query = "SELECT p FROM Pago p WHERE p.idPaciente = :idPaciente"), @NamedQuery(name = "Pago.findByIdDetalle", query = "SELECT p FROM Pago p WHERE p.idDetalle = :idDetalle"), @NamedQuery(name = "Pago.findByPago", query = "SELECT p FROM Pago p WHERE p.pago = :pago"), @NamedQuery(name = "Pago.findByEntrega", query = "SELECT p FROM Pago p WHERE p.entrega = :entrega")})
public class Pago implements Serializable {
    @Transient
    private PropertyChangeSupport changeSupport = new PropertyChangeSupport(this);
    private static final long serialVersionUID = 1L;
    @Id
    @GeneratedValue(strategy=GenerationType.SEQUENCE)
    @Column(name = "nroFactura", nullable = false)
    private Integer nroFactura;
    @Column(name = "fecha")
    private Integer fecha;
    @Column(name = "idPaciente")
    private Integer idPaciente;
    @Column(name = "idDetalle")
    private Integer idDetalle;
    @Column(name = "pago")
    private Float pago;
    @Column(name = "entrega")
    private Float entrega;
    @JoinColumn(name = "idAtencion", referencedColumnName = "idAtencion")
    @ManyToOne
    private Atencion idAtencion;
    @OneToMany(mappedBy = "nrofactura")
    private Collection<Detallepago> detallepagoCollection;

    public Pago() {
    }

    public Pago(Integer nroFactura) {
        this.nroFactura = nroFactura;
    }

    public Integer getNroFactura() {
        return nroFactura;
    }

    public void setNroFactura(Integer nroFactura) {
        Integer oldNroFactura = this.nroFactura;
        this.nroFactura = nroFactura;
        changeSupport.firePropertyChange("nroFactura", oldNroFactura, nroFactura);
    }

    public Integer getFecha() {
        return fecha;
    }

    public void setFecha(Integer fecha) {
        Integer oldFecha = this.fecha;
        this.fecha = fecha;
        changeSupport.firePropertyChange("fecha", oldFecha, fecha);
    }

    public Integer getIdPaciente() {
        return idPaciente;
    }

    public void setIdPaciente(Integer idPaciente) {
        Integer oldIdPaciente = this.idPaciente;
        this.idPaciente = idPaciente;
        changeSupport.firePropertyChange("idPaciente", oldIdPaciente, idPaciente);
    }

    public Integer getIdDetalle() {
        return idDetalle;
    }

    public void setIdDetalle(Integer idDetalle) {
        Integer oldIdDetalle = this.idDetalle;
        this.idDetalle = idDetalle;
        changeSupport.firePropertyChange("idDetalle", oldIdDetalle, idDetalle);
    }

    public Float getPago() {
        return pago;
    }

    public void setPago(Float pago) {
        Float oldPago = this.pago;
        this.pago = pago;
        changeSupport.firePropertyChange("pago", oldPago, pago);
    }

    public Float getEntrega() {
        return entrega;
    }

    public void setEntrega(Float entrega) {
        Float oldEntrega = this.entrega;
        this.entrega = entrega;
        changeSupport.firePropertyChange("entrega", oldEntrega, entrega);
    }

    public Atencion getIdAtencion() {
        return idAtencion;
    }

    public void setIdAtencion(Atencion idAtencion) {
        Atencion oldIdAtencion = this.idAtencion;
        this.idAtencion = idAtencion;
        changeSupport.firePropertyChange("idAtencion", oldIdAtencion, idAtencion);
    }

    public Collection<Detallepago> getDetallepagoCollection() {
        return detallepagoCollection;
    }

    public void setDetallepagoCollection(Collection<Detallepago> detallepagoCollection) {
        this.detallepagoCollection = detallepagoCollection;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (nroFactura != null ? nroFactura.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof Pago)) {
            return false;
        }
        Pago other = (Pago) object;
        if ((this.nroFactura == null && other.nroFactura != null) || (this.nroFactura != null && !this.nroFactura.equals(other.nroFactura))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "podologia.beansDB.Pago[nroFactura=" + nroFactura + "]";
    }

    public void addPropertyChangeListener(PropertyChangeListener listener) {
        changeSupport.addPropertyChangeListener(listener);
    }

    public void removePropertyChangeListener(PropertyChangeListener listener) {
        changeSupport.removePropertyChangeListener(listener);
    }

}
